package cn.tedu.mm.admin.section.server.impl;

import cn.tedu.mm.admin.section.dao.cache.IUserCacheRepository;
import cn.tedu.mm.admin.section.dao.persist.repository.AdminIndexRepository;
import cn.tedu.mm.admin.section.pojo.vo.AdminIndexInfoVO;
import cn.tedu.mm.admin.section.pojo.vo.IndexInfoVO;
import cn.tedu.mm.admin.section.server.AdminIndexServer;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;

@Service
public class AdminIndexServerImpl implements AdminIndexServer {
    @Resource
    AdminIndexRepository indexRepository;
    @Resource
    IUserCacheRepository cacheRepository;

    /**
     * 主页信息
     */
    @Override
    public IndexInfoVO indexInfo() {
        IndexInfoVO indexInfoVO = new IndexInfoVO();
        indexInfoVO.setAdminSum(indexRepository.adminSum())
                .setUserSum(indexRepository.userSum())
                .setFictionSum(indexRepository.fictionSum())
                .setOnLineUserSum(10);
        return indexInfoVO;
    }

    /**
     * 管理员主页信息
     */
    @Override
    public AdminIndexInfoVO adminInfo(Long id) {
        id = 1L;
        AdminIndexInfoVO adminIndexInfoVO = indexRepository.adminRole(id);
        ArrayList<String> list = new ArrayList<>();
        list.add("1");
        list.add("2");
        list.add("3");
        adminIndexInfoVO.setId(id)
                .setPower(list)
                .setLastLoginTime("");
        return adminIndexInfoVO;
    }
}
